#10000/s  在windows 32G内存 2G处理器39.106.34.123:12347
import gevent
import gevent.server
import time
t1=time.time()
t2=time.time()
# 初始化请求计数器
request_count = 0
class EchoServer(gevent.server.StreamServer):
    def handle(self, socket, address):
        global request_count,t2,t1
        while True:
            data = socket.recv(100)
            if not data:
                break
            
            request_count += 1
            if request_count % 10000 == 0:
                t2=time.time()
                print(t2-t1,f"Processed {request_count} requests")
                t1=t2
            socket.sendall(data)
if __name__ == "__main__":
    # 创建普通 StreamServer 实例
    server = EchoServer(('0.0.0.0', 12347))
    server.serve_forever()